<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="pragram" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>查询结果</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link href="/Public/phone/css/swiper-3.0.8.css" rel="stylesheet" type="text/css">
    <link href="/Public/phone/css/iconfont.css" rel="stylesheet" type="text/css">
    <link href="/Public/phone/css/style.css" rel="stylesheet" type="text/css">
    <script src="/Public/phone/js/jquery-1.11.1.min.js"></script>
    <script src="/Public/layer/layer.js"></script>
    <script src="/Public/phone/js/swiper.min-3.1.0.js"></script>
</head>   
<body style="background-color: #f2f2f2;" ng-app="myApp" ng-controller="myCtrl">
	<div class="head">
		<img src="/Public/phone/images/iconfont-zuo.png" onclick="history.go(-1);">
		快递领取列表
	</div>
	<ul class="kdlist">
		<li ng-repeat="vo in list track by $index">
			<div class="cf">
				<div class="l">
					快递信息
					<span ng-bind="vo.take_time">2016-04-22 15:18:00</span>
				</div>
				<button class="r" ng-click="save(vo.id,$index)">领取</button>
			</div>
			<div class="list">
				<div class="l">快件单号</div>
				<span ng-bind="vo.no"></span>
			</div>
			<div class="list">
				<div class="l">货柜编码</div>
				<span ng-bind="vo.container.no"></span>
			</div>
			<div class="list">
				<div class="l">手机号码</div>
				<span ng-bind="vo.phone"></span>
			</div>
			<div class="list">
				<div class="l">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</div>
				<span ng-bind="vo.name"></span>
			</div>
		</li>
	</ul>
	<div class="ajaxMore" ng-if="list.length>=5">加载更多</div>
	<div class="noData" ng-if="list.length<=0">
		<img src="/Public/phone/images/nodata.jpg"/>
		暂无数据,&nbsp;<span>{{ time }}s</span>&nbsp;后自动返回
	</div>
	<script type="text/javascript" src="/Public/phone/js/angular.js"></script>
	<script type="text/javascript">
		var myapp=angular.module("myApp",[]);
		myapp.controller("myCtrl",function($scope,$interval){
			$scope.list=<?php echo ($list); ?>;
			$scope.$watch("list",function(newValue,oldValue){
				if($scope.list==''){
					$scope.time=4;
					$interval(function(){
						$scope.time--;
						if($scope.time<=0){
							history.go(-1);
						}
					},1000);
				}
			},true);
			$scope.save=function(id,index){
				layer.msg('确定领取吗？', {
				  time: 0 //不自动关闭
				  ,btn: ['确定', '取消']
				  ,yes: function(){
				    $.ajax({
						type:"post",
						url:"<?php echo U('List/save');?>",
						data:{"id":id},
						async:false,
						success:function(res){
							layer.msg(res.info,{time:1500});
							if(res.status==1){
								$scope.$apply(function(){
									$scope.list.splice(index,1);
								})
							}
							
						}
					})
				  }
				});
				
			};
			var totalheight = 0;     //定义一个总的高度变量
            var page=2;
            //var data={'where':<?php echo ($where); ?>};
            $(window).scroll(function () {
            	totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
                if ($(document).height() <= totalheight)     //当文档的高度小于或者等于总的高度的时候，开始动态加载数据
                { 
                	//data['p']=page;
                    $.ajax({
                        type:'post',
                        url:'<?php echo U("List/index");?>',
                        data:{'p':page},
                        async:false,
                        dataType: 'json',
                        success:function(res){
                            page++;
                            if(res.info==''){
                            	$(".ajaxMore").text("没有更多数据了");
                            	return false;
                            };
                            $scope.$apply(function(){
                                $scope.list=$scope.list.concat(res.info);
                            })
                        }
                    })
                } 
            }); 
		})
	</script>
</body>
</html>